﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace DAL
{
    public class UserData
    {
        //用户对于相关数据表的操作类
        public void CreatUser(string name, string password, string gender, int age, string email, int authority)
        {
            //添加一个用户的方法
            Users usmodel = new Users();
            usmodel.name = name;
            usmodel.password = password;
            usmodel.gender = gender;
            usmodel.age = age;
            usmodel.email = email;
            usmodel.authority = authority;

            ProjectDBEntities pde = new ProjectDBEntities();
            pde.AddToUsers(usmodel);
            pde.SaveChanges();
        }
        //用户登录验证方法
        public int Login(string Name, string Password)
        {
            //创建上下文对象，用来操作数据库
            ProjectDBEntities pde = new ProjectDBEntities();
            //用linq语句查询出对应输入的用户名的密码
            var u = from c in pde.Users
                    where (c.name == Name && c.password == Password)                   
                    select c;            
            if (u.Count() == 0)
            {
                return 0;
            }
            else
            {
                return 1;               
            }
        }
    }

    public class MovieData
    {
        //对于关于电影的数据操作类
    }

    public class CinemaData
    {
        private string Area{get;set;}

        public CinemaData(string area)
        {
            Area = area;
        }

        //对于电影院的数据的操作类
        public void select()
        {
            ProjectDBEntities a = new ProjectDBEntities();
            var a = from s in a.CinemaData
                    where (s.areas == Area)
                    select a;
            
        }
            
        public void ChangeInfo(string name, string address)
        {
            Cinemas c = new Cinemas();
            c.name = name;
            c.address = address;

            ProjectDBEntities p = new ProjectDBEntities();
            p.SaveChanges();
        }
    }

    public class CommentData
    {
        //对于评论相关的数据操作类
    }

    public class ScoreData
    {
        //对于评分相关的数据操作类
    }
}
